@extends('admin.public.base')
@section('title','新闻列表')
@section('my-css')
<link rel="stylesheet" href="{{url('/css/admin/uniform.css')}}" />
<link rel="stylesheet" href="{{url('/css/admin/select2.css')}}" />
<style>
  
.pagination {
  padding-left: 75%;
  margin: 22px 0;
  border-radius: 4px;
}

.pagination>li {
  display: inline
}

.pagination>li>a,.pagination>li>span {
  position: relative;
  float: left;
  padding: 6px 12px;
  line-height: 1.6;
  text-decoration: none;
  color: #3097D1;
  background-color: #fff;
  border: 1px solid #ddd;
  margin-left: -1px
}

.pagination>li:first-child>a,.pagination>li:first-child>span {
  margin-left: 0;
  border-bottom-left-radius: 4px;
  border-top-left-radius: 4px
}

.pagination>li:last-child>a,.pagination>li:last-child>span {
  border-bottom-right-radius: 4px;
  border-top-right-radius: 4px
}

.pagination>li>a:focus,.pagination>li>a:hover,.pagination>li>span:focus,.pagination>li>span:hover {
  z-index: 2;
  color: #216a94;
  background-color: #eee;
  border-color: #ddd
}

.pagination>.active>a,.pagination>.active>a:focus,.pagination>.active>a:hover,.pagination>.active>span,.pagination>.active>span:focus,.pagination>.active>span:hover {
  z-index: 3;
  color: #fff;
  background-color: #3097D1;
  border-color: #3097D1;
  cursor: default
}

.pagination>.disabled>a,.pagination>.disabled>a:focus,.pagination>.disabled>a:hover,.pagination>.disabled>span,.pagination>.disabled>span:focus,.pagination>.disabled>span:hover {
  color: #777;
  background-color: #fff;
  border-color: #ddd;
  cursor: not-allowed
}
</style>
@endsection
@section('content')
<div id="content">
  <div id="content-header">
    <div id="breadcrumb"> <a href="#" title="Go to Home" class="tip-bottom"><i class="icon-home"></i>后台</a> <a href="#" class="current">新闻列表</a> </div>

    <h1>新闻列表</h1>
  </div>
  <div class="container-fluid">
    <hr>
    <form action="{{url('/admin/index1')}}" method="post">
      <input type="hidden" name="_token" value="{{csrf_token()}}" id="token">
      <button type="button" class="btn btn-large btn-success"><a href="{{url('/admin/addnews')}}">添加新闻</a></button>
      <input type="text" style="margin:0px 6px -4px 1145px;" name='in_search'>
      <button  class='btn btn-warning'>搜索</button>
    </form>
    <div class="row-fluid">
      <div class="span12">
        <div class="widget-box">
          <div class="widget-title"> <span class="icon"><i class="icon-th"></i></span>
            <h5>新闻列表</h5>
          </div>
          <div class="widget-content nopadding">
            <table class="table table-bordered table-striped">
            <input type="hidden" name="_token" value="{{csrf_token()}}" id="token">
              <thead>
                <tr>
                  <th>Id</th>
                  <th>标题</th>
                  <th>简介</th>
                  <th>内容</th>
                  <th>时间</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
              @foreach($info as $v)
                <tr class="even gradeC">
                  <td>{{$v->id}}</td>
                  <td>{{$v->title}}</td>
                  <td>{{$v->describe}}</td>
                  <td class="center">{{$v->content}}</td>
                  <td class="center">{{$v->createtime}}</td>
                  <td style='text-align:center;'>
                    <a href="{{'/admin/news/edit'}}/{{$v->id}}"><input type="button" class="btn btn-info" value="修改"></a>
                    <a href="javascript:delNews({{$v->id}})"><input type="button" class="btn btn-danger" value="删除"></a>
                  </td>
                </tr>
              @endforeach
              </tbody>
            </table>
          </div>         
            
        </div>
      </div>
    </div>
  </div>
  {{$info->links()}}
</div>

<script>
  function delNews(id){
      //定义post传参
      var data = {
        id:id,
      };
      //开启token
      data['_token'] = $('#token').val();
      var url = '/admin/delNews';
      $.post(url,data,function(rest){
          if(rest!==1){
            alert('删除成功');
            // alert("删除成功");window.location.href
            location.replace(location.href);
          }else{
            alert('删除失败');
          }
      });
  } 
</script>
@endsection('content')
